#include<iostream>
#include<vector>
using namespace std;

int minSubArrayLen(int target, vector<int>& nums) {
    int left = 0, right = 0, n = nums.size();
    int sum = nums[left];
    int len = 0;
    while (left < n)
    {
        while (right < n)
        {
            //if (right + 1 == n) break;
            //if (left + 1 == n) break;

            if (sum < target)
            {
                if (right + 1 == n) break;
                right++;
                sum += nums[right];
            }
            else
            {
                len = right - left + 1;
                sum = sum - nums[left];
                left++;
            }
        }
    }
    return len;
}
int main()
{
    vector<int> nums = { 2, 3, 1, 2, 4, 3 };
    cout << minSubArrayLen(7, nums) << endl;
    return 0;
}